package com.android.plc.ui.control;

import android.content.Context;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;

import com.android.plc.CONST.COMMAND;
import com.android.plc.R;

public class ProjectorControl extends NormalControl implements OnClickListener
{
	private Button mVideo1Btn;
	private Button mVideo2Btn;
	private Button mVideo3Btn;
	private Button mConfirmBtn;

	private static final int OFFSET_1 = 1;
	private static final int OFFSET_2 = 2;

	public static final int DATA = 0x64;

	public ProjectorControl(Context context, ViewGroup view, int res_id)
	{
		super(context, view, res_id);
	}

	public ProjectorControl(Context context, ViewGroup view)
	{
		super(context, view, R.layout.control_projector);
	}

	@Override
	public void initView(ViewGroup view)
	{
		super.initView(view);
		
		mVideo1Btn = (Button) view.findViewById(R.id.btn_video_1);
		mVideo2Btn = (Button) view.findViewById(R.id.btn_video_2);
		mVideo3Btn = (Button) view.findViewById(R.id.btn_video_3);
		mConfirmBtn = (Button) view.findViewById(R.id.btn_confirm);

		mVideo1Btn.setOnClickListener(this);
		mVideo2Btn.setOnClickListener(this);
		mVideo3Btn.setOnClickListener(this);
		mConfirmBtn.setOnClickListener(this);
	}

	public void onClick(View v)
	{
		super.onClick(v);
		switch (v.getId())
		{
		case R.id.btn_video_1:
			sendCommand(OFFSET_1, COMMAND.ON, DATA, 0);
			break;
		case R.id.btn_video_2:
			sendCommand(OFFSET_1, COMMAND.OFF, 0, 0);
			break;
		case R.id.btn_video_3:
			sendCommand(OFFSET_2, COMMAND.ON, DATA, 0);
			break;
		case R.id.btn_confirm:
			sendCommand(OFFSET_2, COMMAND.OFF, 0, 0);
			break;
		default:
			break;
		}
	}

}
